package com.kb.order.controller;

import com.kb.order.pojo.Order;
import com.kb.order.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping("pay")
public class PayController {

    @Autowired
    private IOrderService orderService;

    @RequestMapping("/toOrderList")
    public void toOrderList(String out_trade_no, HttpServletResponse response, HttpServletRequest request) throws IOException {
//&outTradeNo=201911046363&pid=2088102179997955&type=1
        System.out.println("订单支付返回的订单号："+out_trade_no);
        //修改数据库
        Order order = new Order();
        order.setOrderId(out_trade_no);
        order.setStatus(new Long(0));
        orderService.update(order);
        //return "user_orderlist";
        response.sendRedirect("http://localhost:8080/html/user_orderlist.html");
    }
}
